//
//  Singleton.m
//  单例模式
//
//  Created by apple on 15/9/15.
//  Copyright (c) 2015年 戴维营. All rights reserved.
//

#import "Singleton.h"

static Singleton *singleton = nil;

@implementation Singleton


//在这个类点类方法调用之前一定会调用的；

+ (void)initialize
{
//    singleton = [[self alloc] init];
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        
        singleton = [Singleton new];
        
//        singleton.text = @" cao!";
    });
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
    
    if (singleton == nil)
    {
        //用父类初始化；
        singleton = [super allocWithZone:zone];
    }
    
    return singleton;
}

+ (instancetype)shareManager
{
    return singleton;
}


@end
